import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import 'font-awesome/css/font-awesome.css'
import axios from 'axios';
import common from '@/components/common/common'
//自定义全局变量
Vue.prototype.common = common;


Vue.config.productionTip = false
Vue.prototype.$http = axios;
//ajax后端请求接口地址:  ../src/api/api.js  
axios.defaults.baseURL = 'http://127.0.0.1:8000'; //指定前端地址，公网IP
Vue.use(ElementUI);

//解决message多次触发只显示最后一个
import {Message} from 'element-ui';
let messageInstance = null;
const resetMessage = (options) => {
  if (messageInstance) {
    messageInstance.close()
  }
  messageInstance = Message(options)
};
['error','success','info','warning'].forEach(type => {
  resetMessage[type] = options => {
    if(typeof options === 'string'){
      options = {
        message:options
      }
    }
    options.type = type
    return resetMessage(options)
  }
})
// Vue.prototype.$message = resetMessage;

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
